$(function () {
    //alert(1)
    $('#id_captcha_1').blur(function () {
        var key = $('#id_captcha_0').val();
        var phone= $('#id_captcha_1').val();
        //alert(key+phone);
        $.ajax({
            type:'get',
            url:'http://127.0.0.1:8000/user/img',
            data:{'hashkey':key,'code':phone},
            success(meg){
                //alert(meg)
                console.log(meg)
                if (meg.status==1){
                    //alert('sucess')
                    //$('#id_captcha_1').attr('value','正确')
                }else{
                    alert('验证码错误')
                    //$('#id_captcha_1').attr('value','错误')
                }
            }
            }
        )
    });
    $('#captcha').click(function () {
        $.ajax({
                type:"get",
                url:"http://127.0.0.1:8000/user/refresh",
                success(msg){
                    msg=JSON.parse(msg)
                    console.log(msg);
                    //alert(msg);
                    //alert(msg.hashkey);//hashkey
                    //alert(msg.image_url);
                    //$('img_code').attr("src","http://127.0.0.1:8000"+msg.image_url)
                    $('#captcha').attr('src',msg.image_url);
                    $('#id_captcha_0').attr('value',msg.hashkey)
                    //document.getElementById('captcha').src = msg.image_url;
                    //document.getElementById('id_captcha_0').value = msg.hashkey
                }
            })
    })


});